// utils/svg-icons.js
const SVG_ICONS = {
  search: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M7.5 1C11.366 1 14.5 4.134 14.5 8C14.5 11.866 11.366 15 7.5 15C3.634 15 0.5 11.866 0.5 8C0.5 4.134 3.634 1 7.5 1Z" stroke="currentColor" stroke-width="1.5" fill="none"/>
    <path d="M15.5 15L11.5 11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
  </svg>`,

  location: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M8 1C5.243 1 3 3.243 3 6C3 9.5 8 15 8 15S13 9.5 13 6C13 3.243 10.757 1 8 1Z" stroke="currentColor" stroke-width="1.5" fill="none"/>
    <circle cx="8" cy="6" r="2" stroke="currentColor" stroke-width="1.5" fill="none"/>
  </svg>`,

  camera: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M2 5C2 4.447 2.447 4 3 4H4L5 2H11L12 4H13C13.553 4 14 4.447 14 5V13C14 13.553 13.553 14 13 14H3C2.447 14 2 13.553 2 13V5Z" stroke="currentColor" stroke-width="1.5" fill="none"/>
    <circle cx="8" cy="9" r="2.5" stroke="currentColor" stroke-width="1.5" fill="none"/>
  </svg>`,

  gallery: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <rect x="2" y="3" width="12" height="10" rx="1" stroke="currentColor" stroke-width="1.5" fill="none"/>
    <path d="M2 10L5 7L8 10L11 7L14 10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
    <circle cx="5" cy="6" r="1" fill="currentColor"/>
  </svg>`,

  like: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M8 14L7 13C3.5 9.5 1 7 1 4.5C1 2.5 2.5 1 4.5 1C5.5 1 6.5 1.5 7 2.5C7.5 1.5 8.5 1 9.5 1C11.5 1 13 2.5 13 4.5C13 7 10.5 9.5 7 13L8 14Z" stroke="currentColor" stroke-width="1.5" fill="none"/>
  </svg>`,

  "like-filled": `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M8 14L7 13C3.5 9.5 1 7 1 4.5C1 2.5 2.5 1 4.5 1C5.5 1 6.5 1.5 7 2.5C7.5 1.5 8.5 1 9.5 1C11.5 1 13 2.5 13 4.5C13 7 10.5 9.5 7 13L8 14Z" fill="currentColor"/>
  </svg>`,

  comment: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M2 2H14V10H6L2 14V2Z" stroke="currentColor" stroke-width="1.5" fill="none"/>
  </svg>`,

  share: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <circle cx="12" cy="4" r="2" stroke="currentColor" stroke-width="1.5" fill="none"/>
    <circle cx="4" cy="8" r="2" stroke="currentColor" stroke-width="1.5" fill="none"/>
    <circle cx="12" cy="12" r="2" stroke="currentColor" stroke-width="1.5" fill="none"/>
    <path d="M6 7L10 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
    <path d="M6 9L10 11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
  </svg>`,

  plus: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M8 1V15" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
    <path d="M1 8H15" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
  </svg>`,

  arrow: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M6 4L10 8L6 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
  </svg>`,

  empty: `<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
    <circle cx="32" cy="32" r="30" stroke="#E5E5E5" stroke-width="2" fill="none"/>
    <path d="M20 24C20 21.791 21.791 20 24 20H40C42.209 20 44 21.791 44 24V40C44 42.209 42.209 44 40 44H24C21.791 44 20 42.209 20 40V24Z" stroke="#E5E5E5" stroke-width="2" fill="none"/>
    <path d="M20 32L28 24L36 32L44 24" stroke="#E5E5E5" stroke-width="2" stroke-linecap="round"/>
    <circle cx="28" cy="28" r="2" fill="#E5E5E5"/>
  </svg>`,
};

// 获取SVG图标内容
function getSvgIcon(name, size = 16, color = "#333333") {
  const svgContent = SVG_ICONS[name];
  if (!svgContent) {
    console.warn(`SVG icon "${name}" not found`);
    return "";
  }

  // 替换颜色和尺寸
  let processedSvg = svgContent
    .replace(/currentColor/g, color)
    .replace(/width="[^"]*"/, `width="${size}"`)
    .replace(/height="[^"]*"/, `height="${size}"`);

  return processedSvg;
}

module.exports = {
  SVG_ICONS,
  getSvgIcon,
};
